package com.guguskins.back.common.mq;

import com.guguskins.back.service.GuRollService;
import com.rabbitmq.client.Channel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class RabbitMQConsumer {

    @Autowired
    private GuRollService rollService;

    @RabbitListener(queues = "email_guguskins_queue")
    private void emailReceiverMessage(String email, Channel channel, Message msg) {
        //生成验证码

        //发送邮箱
    }

    @RabbitListener(queues = "guguskins_roll_delay_queue")
    private void rollDelayReceiverMessage(Long rollId, Channel channel, Message msg) {
        System.err.println("接收消息队列");
        System.err.println("rollId==>" + rollId);
        //开奖
        boolean result = rollService.lottery(rollId);
        log.info("roll房开奖，rollId：{}，处理结果：{}", rollId, result);

//        boolean result = groupBuyMainService.dissolve(gbmId);
//        log.info("处理过期拼团,拼团id:{},处理结果:{}", gbmId, result);
    }

}
